<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>前端用户解封日志</title>
    <script src="/jquery/jquery-3.2.1.min.js"></script>
    <script src="/layui/layui.js"></script>
    <link rel="stylesheet" href="/layui/css/layui.css"/>
    <link rel="stylesheet" href="/css/usermodule/user-list.css"/>
</head>
<body>
    <div class="layui-row" >
        <div class="layui-col-md11">
            <div class="layui-card headerCenter">
                <div class="layui-card-header backColor">
                    前端用户解封日志表
                    <div class="btnRight" style="margin-bottom: 10px">
                        <button onclick="refresh()" type="button" class="layui-btn layui-btn layui-btn-sm">
                            <i class="layui-icon layui-icon-refresh-1"></i>
                            刷新
                        </button>
                        <button onclick="backOff()" type="button" class="layui-btn layui-btn layui-btn-sm">
                            <i class="layui-icon layui-icon-return"></i>
                            返回
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--筛选查询-->
    <div class="layui-row">
        <div class="layui-col-md11">
            <div class="layui-card headerCenter">
                <div class="layui-card-header backColor">
                    <i class="layui-icon">&#xe615;</i>
                    筛选查询
                </div>
                <div class="layui-card-body">
                    <form class="layui-form" id="myFrom">
                        <div class="layui-form-item">
                            <div class="floa">
                                <label class="layui-form-label fontsize" >用户账号：</label>
                                <div class="layui-input-inline" style="margin-right: -30px; padding-right: -30px">
                                    <input type="text" name="account" required lay-verify="required" placeholder="用户账号" autocomplete="off" class="layui-input inp">
                                </div>
                            </div>
                            <div class="floa">
                                <label class="layui-form-label fontsize">用户昵称：</label>
                                <div class="layui-input-inline fontsize inp">
                                    <input type="text" name="nickname" required lay-verify="required" placeholder="用户昵称" autocomplete="off" class="layui-input inp">
                                </div>
                            </div>

                            <label class="layui-form-label fontsize">解封时间：</label>
                            <div class="layui-input-inline">
                                <input type="text" id="test1" name="endDate" required lay-verify="required" placeholder="注册时间" autocomplete="off" class="layui-input inp">
                            </div>

                            <span style="float:right;">
                                        <button onclick="selProduct()" type="button" class="layui-btn layui-btn layui-btn-sm">
                                            <i class="layui-icon layui-icon-search"></i> 搜索
                                        </button>
                                        <button onclick="refresh()" type="button" class="layui-btn layui-btn-warm layui-btn layui-btn-sm">
                                            <i class="layui-icon layui-icon-refresh-1"></i> 重置
                                        </button>
                                    </span>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-col-md11">
            <div class="layui-card headerCenter">
                <div class="layui-card-header backColor">
                    <i class="layui-icon">&#xe615;</i>
                    前端用户解封日志
                </div>
            </div>
        </div>
    </div>
    <div class="layui-col-md11" style="margin-left: 19px">
        <table id="demo" lay-filter="test"></table>
    </div>
    <input type="hidden" name="userId"/>
</body>
    <script>
        var form;
        var $;
        var table;
        var layer;
        var upload;
        var laydate;
        layui.use(['laydate','form','jquery','table','layer','upload'],function() {
            form = layui.form;
            laydate = layui.laydate;
            $ = layui.jquery;
            table = layui.table;
            layer = layui.layer;
            upload = layui.upload;

            laydate.render({
                elem: '#test1', //指定元素
                type:'datetime'
            });
        });

        function refresh() {
            $('#myFrom')[0].reset();
            start();
        }
        start();
        //渲染
        function start() {
            $.ajax({
                url:'/UserList/queryUnseal',
                dataType:'json',
                success:function (data) {
                    data = data.data;
                    startTab(data);
                }
            });
        }

        function startTab(data) {
            table.render({
                elem:'#demo',
                page:true,
                data:data,
                cols:[[
                    {checkbox:true},//复选框靠左
                    {title:'序号',width:60,type:'numbers'},

                    {field:"account",title:"被封停用户账号",align:'center'},
                    {field:"nickname",title:"被封停用户昵称",align:'center'},
                    {field:"endDate",title:"解封时间",align:'center'},
                    {title:"封停原因",align:'center',templet:function (data) {
                        if(data.reason == ""){
                            return "无";
                        }else{
                            return data.reason;
                        }
                        }},
                    {title:"封停天数",align:'center',templet:function (data) {
                            return data.days+"天";
                        }},
                    {title:"操作",align:'center',templet:function (data) {
                            return "<a class='fontColor' onclick='delUnseal("+data.id+")' href='javascript:;'>删除</a>";
                        }},
                ]]
            });
        }

        //搜索
        function selProduct() {
            var account = $('input[name = account]').val();
            var nickname = $('input[name = nickname]').val();
            var endDate = $('input[name = endDate]').val();
            $.ajax({
                url:'/UserList/queryUnseal',
                dataType:'json',
                data:{"account":account,"nickname":nickname,"endDate":endDate},
                success:function (data) {
                    data = data.data;
                    startTab(data);
                }
            });
        }

        function delUnseal(id) {
            layer.open({
                type: 1,
                content: "<div style='font-size: 20px ; margin:30px  ;'>是否删除此信息?</div>",
                area: ['300px', '200px'],
                btn: ["确定", "取消"],
                yes: function (index, layero) {
                    $.ajax({
                        url: '/UserList/delUnseal',
                        dataType: 'json',
                        data: {"id": id},
                        success: function (data) {
                            if (data.data) {
                                layer.msg("删除成功");
                                start();
                            } else {
                                layer.msg("删除失败");
                            }
                        }
                    });
                }
            });
        }

        function backOff() {
            var arr = localStorage.getItem("numArr");
            var numArr = arr.split(",");
            numArr.pop();
            window.parent.layui.element.tabChange('tab',numArr[numArr.length - 1]);
            localStorage.setItem("numArr",numArr);
        }
    </script>
</html>